//
// Created by zhouwd on 2019/7/29.
//

#ifndef IPTVSETTING_MEDIA_RENDER_H
#define IPTVSETTING_MEDIA_RENDER_H
#include <cstdlib>
#include <cstring>
#include <EGL/egl.h>
#include <GLES3/gl3.h>
#include "log_util.cpp"
#include "media_video_frame.h"
#include "media_video_frame_notify.h"
typedef class _MEDIA_RENDER : public MediaVideoFrame {
private:
    int mWidth, mHeight;
    size_t yBufferSize, uBufferSize, vBufferSize;
    uint8_t *yBuffer,*uBuffer,*vBuffer;
    GLuint id_y, id_u, id_v, program; // Texture id
    GLuint *vboIds;
    GLint textureUniformY, textureUniformU, textureUniformV;
    MediaVideoFrameNotify *mediaVideoFrameNotify;
    GLuint createShader(GLenum shaderType, const char* src);
    GLuint createProgram(const char* vtxSrc, const char* fragSrc);
    FILE * pFile;
public:
    int init(int width, int height, const char *mPreviewVertexShaderBuffer, const char *mPreviewFragmentShaderBuffer);
    int setMediaVideoFrameNotify(MediaVideoFrameNotify *mediaVideoFrameNotify);
    int step();

    int resize();
    int prepare();
    int updateVideoFrameData(uint8_t *data, int decodeWidth, int decodeHeight);
    int destory();
} MediaRender;


#endif //IPTVSETTING_MEDIA_RENDER_H
